package com.thp.bigdata.thread.testThread;

public class MySynchronized {
	
	
	
	public static void main(String[] args) {
		
		final MySynchronized mySynchronized1 = new MySynchronized();
		final MySynchronized mySynchronized2 = new MySynchronized();
		
		
		new Thread("thread1") {
			public void run() {
				synchronized(mySynchronized1) {
					try {
						System.out.println(this.getName() + " start");
						int i = 1 / 0;
						Thread.sleep(2000);
						System.out.println(this.getName() + "醒来了 !");
						System.out.println(this.getName() + " end");
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
			}
		}.start();
		
		new Thread("thread2") {
			public void run() {
				synchronized (mySynchronized1) {
					System.out.println(this.getName() + " satrt");
					System.out.println(this.getName() + " end");
				}
			}
		}.start();
		
		
		
	}
	
	
}
